Skip to content

关闭数据库 - CloseDatabase

函数简介

关闭已打开的数据库,释放相关资源。

接口名称

CloseDatabase

DLL调用

c
int CloseDatabase(long ola, long db);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
db长整数型数据库连接句柄,由 OpenDatabase 接口生成。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0) {
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0)
{
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
db = ola.OpenDatabase("data/app.db", "")
if db != 0:
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0) {
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
cpp
var ola = com("OlaPlug.OlaSoft")
var db = ola.OpenDatabase("data/app.db", "")
if(db) {
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
db = ola.OpenDatabase("data/app.db", "")
If db <> 0 Then
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
text
.局部变量 ola, OLAPlug
ola.创建 ()
db = ola.OpenDatabase (“data/app.db“, ““)
.如果真 (db ≠ 0)
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var db = ola.OpenDatabase("data/app.db", "");
if(db){
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 db = ola.OpenDatabase("data/app.db", "")
如果真 (db ≠ 0)
{
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0) {
    ola.CloseDatabase(db); // 必须关闭,否则连接泄漏
}

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long db = OpenDatabase(instance, "data/app.db", "");
if (db != 0) {
    CloseDatabase(instance, db);
}
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();

long instance = CreateCOLAPlugInterFace();
long db = OpenDatabase(instance, "data/app.db", "");
if (db != 0)
{
    CloseDatabase(instance, db);
}
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
db = ola.OpenDatabase(instance, b"data/app.db", b"")
if db:
    CloseDatabase(instance, db);
}

返回值

1 成功,0 失败。

注意事项

  • 关闭数据库后,相关的数据库对象指针将不再有效,后续操作将导致未定义行为。
  • 确保在不再使用数据库时调用此函数,以释放相关资源。